Skip to content

[Enh] Add finer FastMathFlag control#789

Open
sjfeng1999 wants to merge 8 commits into
mainfrom
pr/enh-fmath-flag
Open

[Enh] Add finer FastMathFlag control#789
sjfeng1999 wants to merge 8 commits into
mainfrom
pr/enh-fmath-flag

Conversation

@sjfeng1999

Copy link
Copy Markdown
Collaborator

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an “ambient” fast-math mechanism so floating-point ops can automatically inherit fastmath flags from (1) a with fx.fastmath(...) context and (2) a compile hint (kernel/JIT scope), while still allowing per-op explicit overrides.

Changes:

  • Add a thread-local ambient fastmath context manager and propagate it through overloaded float ops and selected helpers.
  • Teach math-dialect wrappers to inherit ambient fastmath when fastmath isn’t explicitly provided.
  • Apply compile-hint fastmath as a scope around kernel/JIT body emission and add tests for scoping/overrides/cache keys.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unit/test_fastmath_context.py New tests for ambient fastmath propagation, overrides, and hint/cache-key behavior.
python/flydsl/expr/utils/arith.py Adds thread-local ambient fastmath context + propagates flags through float operators and selected helpers.
python/flydsl/expr/typing.py Attempts to propagate fastmath into Vector.reduce, but currently introduces a NameError.
python/flydsl/expr/math.py Enhances wrapper decorator to inject ambient fastmath and support non-first “exemplar” operands.
python/flydsl/expr/arith.py Extends arith wrapper surface and uses the math wrapper decorator for result typing.
python/flydsl/compiler/kernel_function.py Applies compile-hint fastmath via a context manager around kernel-body emission.
python/flydsl/compiler/jit_function.py Applies compile-hint fastmath via a context manager around JIT-body emission.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/flydsl/expr/typing.py
Comment thread python/flydsl/expr/utils/arith.py Outdated
Comment thread tests/unit/test_fastmath_context.py Outdated
Comment thread tests/unit/test_fastmath_context.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants